package com.ruoyi.web.controller.ufox;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ufox.domain.SysWeektimerSetting;
import com.ruoyi.ufox.service.ISysWeektimerSettingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 周模式设置Controller
 * 
 * @author ruoyi
 * @date 2022-08-31
 */
@RestController
@RequestMapping("/system/settingufox")
public class SysWeektimerSettingController extends BaseController
{
    @Autowired
    private ISysWeektimerSettingService sysWeektimerSettingService;

    /**
     * 查询周模式设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:settingufox:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysWeektimerSetting sysWeektimerSetting)
    {
        startPage();
        List<SysWeektimerSetting> list = sysWeektimerSettingService.selectSysWeektimerSettingList(sysWeektimerSetting);
        return getDataTable(list);
    }

    /**
     * 导出周模式设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:settingufox:export')")
    @Log(title = "周模式设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysWeektimerSetting sysWeektimerSetting)
    {
        List<SysWeektimerSetting> list = sysWeektimerSettingService.selectSysWeektimerSettingList(sysWeektimerSetting);
        ExcelUtil<SysWeektimerSetting> util = new ExcelUtil<SysWeektimerSetting>(SysWeektimerSetting.class);
        util.exportExcel(response, list, "周模式设置数据");
    }

    /**
     * 获取周模式设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:settingufox:query')")
    @GetMapping(value = "/{settingId}")
    public AjaxResult getInfo(@PathVariable("settingId") Long settingId)
    {
        return AjaxResult.success(sysWeektimerSettingService.selectSysWeektimerSettingBySettingId(settingId));
    }

    /**
     * 新增周模式设置
     */
    @PreAuthorize("@ss.hasPermi('system:settingufox:add')")
    @Log(title = "周模式设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWeektimerSetting sysWeektimerSetting)
    {
        return toAjax(sysWeektimerSettingService.insertSysWeektimerSetting(sysWeektimerSetting));
    }

    /**
     * 修改周模式设置
     */
    @PreAuthorize("@ss.hasPermi('system:settingufox:edit')")
    @Log(title = "周模式设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWeektimerSetting sysWeektimerSetting)
    {
        return toAjax(sysWeektimerSettingService.updateSysWeektimerSetting(sysWeektimerSetting));
    }

    /**
     * 删除周模式设置
     */
    @PreAuthorize("@ss.hasPermi('system:settingufox:remove')")
    @Log(title = "周模式设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{settingIds}")
    public AjaxResult remove(@PathVariable Long[] settingIds)
    {
        return toAjax(sysWeektimerSettingService.deleteSysWeektimerSettingBySettingIds(settingIds));
    }
}
